package com.lw.common.config;

import cn.dev33.satoken.exception.NotLoginException;
import com.lw.common.utils.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 登录异常
     */
    @ExceptionHandler
    public ResultVo<Object> handlerException(NotLoginException e) {
        e.printStackTrace();
        return ResultVo.error(506,"token失效,请先登录");
    }

    // 全局异常拦截
    @ExceptionHandler
    public ResultVo<Object> handlerException(Exception e) {
        e.printStackTrace();
        return ResultVo.error(e.getMessage());
    }

}
